package com.example.benefitcommunity.controller;

import com.example.benefitcommunity.entity.BcMerchant;
import com.example.benefitcommunity.entity.BcMerchantDetail;
import com.example.benefitcommunity.entity.Result;
import com.example.benefitcommunity.service.BcMerchantDetailService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 商户管理明细明细表(BcMerchantDetail)表控制层
 *
 * @author makejava
 * @since 2025-08-21 14:48:41
 */
@Tag(name = "商户管理明细")
@CrossOrigin
@RestController
@RequestMapping("bcMerchantDetail")
public class BcMerchantDetailController {
    /**
     * 服务对象
     */
    @Resource
    private BcMerchantDetailService bcMerchantDetailService;

    /**
     * 通过查询数据
     *
     * @param goodname 姓名
     * @param pagenum  页码
     * @param pagesize 页大小
     * @return 数据
     */
    @Operation(description = "商户管理明细查询")
    @GetMapping("list")
    public Result<Object> queryByMerchantDetail(String type, String goodname, Integer isupdown, Integer merchantid, Integer pagenum, Integer pagesize) {
        return this.bcMerchantDetailService.queryByMerchantDetail(type, goodname, isupdown,merchantid, pagenum, pagesize);
    }


    /**
     * 新增数据
     *
     * @param bcMerchantDetail 实体
     * @return 新增结果
     */
    @Operation(description = "新增商户管理明细")
    @PostMapping("add")
    public Result<Object> add(@RequestBody BcMerchantDetail bcMerchantDetail) {
        return this.bcMerchantDetailService.insert(bcMerchantDetail);
    }

    /**
     * 编辑数据
     *
     * @param bcMerchantDetail 实体
     * @return 编辑结果
     */
    @Operation(description = "编辑商户管理明细")
    @PutMapping("edit")
    public Result<Object> edit(@RequestBody BcMerchantDetail bcMerchantDetail) {
        return this.bcMerchantDetailService.update(bcMerchantDetail);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @Operation(description = "删除商户管理明细")
    @DeleteMapping("delete")
    public Result<Object> deleteById(Integer[] id) {
        return this.bcMerchantDetailService.deleteById(id);
    }

}

